<template>
	<view class="page">
		<view class="my-nav-bar">
			<uni-nav-bar
				color="#ffffff" 
				background-color="transparent" 
				:status-bar="true" 
				left-icon="arrowleft" 
				left-text="返回" 
				@clickLeft="goBack" 
				fixed="true"
			/>
		</view>
		<image class="bg" src="https://www.innovationgloble.com/wxs/img/wx/pay-success.png"></image>
		
		<!-- pay-success-content -->
		
		<image class="content mt40" src="https://www.innovationgloble.com/wxs/img/wx/pay-success-new.png"></image>
		<view class="invite-title-t">恭喜您获得<text>{{inviteNum}}</text> 积分大礼包</view>
		<view class="invite-title">邀好友注册，一起瓜分吧！</view>
		<button class="share-btn"  type="default"  open-type="share">
			去分享
		</button>	
		<view class="order-btn" @click="toOrder">
			查看订单
		</view>
	</view>
</template>

<script>
	import uniNavBar from '@/components/uni-nav-bar/uni-nav-bar.vue'
	import {
		programName
	} from '@/common/config'
	export default {
		components: {
			uniNavBar,
		},
		data() {
			return {
               shareNum:'',
			   inviteNum:'',
			   delta:1
			}
		},
		onLoad(option) {
			this.getInviteCode();
			this.getInviteNum();
			console.log('传递的option',option)
			if(option.delta){
				this.delta = option.delta
			}
		},
		onShareAppMessage(res) {
			if (res.from === 'button') { // 来自页面内分享按钮
				console.log(res.target)
			}
			const userInfo = uni.getStorageSync('userInfo');
			const userName = userInfo.realName || '';
			const userId = userInfo.userId || '';
			let shareNum = this.shareNum ;
		    shareNum = shareNum.replace(/\=/ig,"%3D");
			return {
				title: `快来和我一起加入${programName}成果转化联盟吧！`,
				path: `/pagesA/accept-invite/accept-invite?name=${userName}&id=${userId}&shareNum=${shareNum}&inviteNum=${this.inviteNum}`,
				imageUrl: 'https://www.innovationgloble.com/wxs/img/wx/accept-new.png'
			}
		},
		methods: {
			toOrder(){
				uni.navigateTo({
					url:'/pagesB/my-order/my-order'
				})
			},
			goBack(){
				console.log('点击了',this.delta)
				uni.navigateBack({
					delta:parseFloat(this.delta)
				}
				);
			},
			//獲取邀请积分数量
			getInviteNum(){
				this.$request.get({
					url:'UserIntegralHistory/selectMyShareIntegral'
				}).then(res=>{
					console.log('邀请积分数量',res)
					this.inviteNum = res;
				})
			},
			//获取邀请码
			getInviteCode(){
				this.$request.get({
					url:'/user/getShareUrl'
				}).then(res=>{
					console.log('邀请码',res)
					this.shareNum = res;
				})
			}
		}
	}
</script>

<style scoped lang="less">
	.page {
		width: 100%;
		min-height: 100vh;
		// background-color: #F5F6F9;
		background-color: #fff;
		
		.bg{
			width: 100%;
			object-fit: contain;
		}
		
		.content{
			padding-left: 20%;
			padding-right: 20%;
			width: 50%;
			object-fit: contain;
		}
		
		.mt40{
			margin-top: 40upx;
		}
		.invite-title {
			font-size:30upx;
			font-family:PingFangSC-Medium,PingFang SC;
			font-weight:500;
			color:rgba(68,68,68,1);
			line-height:60upx;
			text-align: center;
			margin: 0 auto;
		}
		.invite-title-t{
			color: #444;
			font-size: 38upx;
			text-align: center;
			font-weight: bold;
			text{
				
				color: #DE5A02;font-size: 56upx;}
		}
		.share-btn{
			width:80%;
			margin-left: 10%;
			margin-right: 10%;
			margin-top: 50upx;
			height:98upx;
			background:linear-gradient(180deg,rgba(0,139,255,1) 0%,rgba(25,109,236,1) 100%);
			border-radius:49upx;
			
			line-height:98upx;
			font-size:32upx;
			font-family:PingFangSC-Regular,PingFang SC;
			font-weight:400;
			color:rgba(255,255,255,1);
			text-align: center;
		}
		.share-btn::after{
			border: none;
		}
		.order-btn{
			font-size: 32upx;
			margin: 20upx 0;
			width: 100%;
			text-align: center;
			color: #196DEC;
		}
	}
</style>
